import request from '@/utils/request'

/**
 * 保存数据
 * @param params
 * @param id
 * @returns AxiosPromise
 */
export function save(params, id = null) {
  return request({
    url: '/print/tpl/' + (id ? 'update/' + id : 'store'),
    method: 'post',
    data: params
  })
}

/**
 * 模板分页
 * @returns AxiosPromise
 * @param params
 */
export function paginate(params) {
  return request({
    url: '/print/tpl/paginate',
    method: 'get',
    params
  })
}

/**
 * 模板分页
 * @returns AxiosPromise
 * @param params
 */
export function getPrintTplList(params) {
  return request({
    url: '/print/tpl/paginate',
    method: 'get',
    params: Object.assign(params, { is_list: 1 })
  })
}

/**
 * 模板信息
 * @returns AxiosPromise
 * @param tpl_id
 */
export function info(tpl_id) {
  return request({
    url: '/print/tpl/info/' + tpl_id,
    method: 'get'
  })
}

/**
 * 删除模板
 * @returns AxiosPromise
 * @param tpl_id
 */
export function destroy(tpl_id) {
  return request({
    url: '/print/tpl/destroy/' + tpl_id,
    method: 'delete'
  })
}

/**
 * 节点列表
 * @param params
 * @returns AxiosPromise
 */
export function classifyLists(params) {
  return request({
    url: '/print/tpl/classify/lists',
    method: 'get',
    data: params
  })
}

/**
 * 保存数据
 * @param params
 * @param id
 * @returns AxiosPromise
 */
export function classifySave(params, id = null) {
  return request({
    url: '/print/tpl/classify/' + (id ? 'update/' + id : 'store'),
    method: 'post',
    data: params
  })
}

/**
 * 删除数据
 * @param id
 * @returns AxiosPromise
 */
export function classifyInfo(id) {
  return request({
    url: '/print/tpl/classify/info/' + id,
    method: 'get'
  })
}

/**
 * 删除数据
 * @param id
 * @returns AxiosPromise
 */
export function classifyDestroy(id) {
  return request({
    url: '/print/tpl/classify/destroy/' + id,
    method: 'delete'
  })
}
